﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nature.Data.CkMarkup
{
    public partial class CkReagent
    {
    }

    public static partial class Extensions
    {
        public static double GetReagentStoichiometricCoefficient(this IEnumerable<CkReagent> reagents, string reagentID)
        {
            return reagents
                .Where(i => i.ReagentID == reagentID)
                .Sum(i=> i.Coefficient.HasValue ? i.Coefficient.Value : 1.0d);
        }

        public static int DistinctReagentsCount(this IEnumerable<CkReagent> reagents)
        {
            return reagents
                .Select(i => i.ReagentID).Distinct().Count();
        }

    }
}
